package com.delivery.deliverysystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.delivery.deliverysystem.pojo.DO.DeliveryColor;
import com.delivery.deliverysystem.service.DeliveryColorService;
import com.delivery.deliverysystem.dao.DeliveryColorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【delivery_color(单据颜色表)】的数据库操作Service实现
* @createDate 2025-04-23 16:53:35
*/
@Service
public class DeliveryColorServiceImpl extends ServiceImpl<DeliveryColorMapper, DeliveryColor>
    implements DeliveryColorService{

    @Autowired
    private DeliveryColorMapper deliveryColorMapper;


    @Override
    public List<DeliveryColor> getAllDeliveryColor() {
        return deliveryColorMapper.selectList(null);
    }

    @Override
    public List<DeliveryColor> updateColor(List<DeliveryColor> list) {
        for(DeliveryColor d:list){
            Integer status = d.getStatus();
            DeliveryColor originColor = deliveryColorMapper.selectOne(new QueryWrapper<DeliveryColor>().eq("status", status));
            originColor.setColor(d.getColor());
            deliveryColorMapper.updateById(originColor);
        }
        return deliveryColorMapper.selectList(null);
    }
}




